home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48_1 / stat.dis < prev    next >
Text File  |  1995-03-23  |  8KB  |  246 lines

  1. Subject: Solve statistic problem with various distribution eqs
  2.  
  3. This is a program for HP-48SX which would be interesting to solve
  4. statistical problem about a lot of distribution equation.
  5. Sorry for my poor english, I hope this explanation clear for
  6. understand the program. Strip the comment and download above here.
  7. ----------------------------------------------------------------------
  8. %%HP: T(3)A(D)F(.);
  9.     DIR
  10.       BINO
  11.         DIR
  12.     @ Contents:
  13.     @ Bino: Equation of binomial distribution
  14.     @       Set value of 'n' and 'p' or use solvr.
  15.     @ P: Computes the binomial value for a given k value
  16.     @    using the values of 'n' 'p' stored into the variables.
  17.     @ \Gm: (mu)  mean of distribution.
  18.     @ \Gs2: (Sigma^2) Standard variation.
  19.     @ G: equation of momentum generator.
  20.     @ RANGE: Computes the cumulative value between
  21.     @        a and b.
  22.           Bino 'n!/(k!*(n-k)!)*p^k*(1-p)^(n-k)'
  23.           P
  24.             \<< \-> k 'n!/(k!*(n-k)!)*p^k*(1-p)^(n-k)' \>>
  25.           \Gm
  26.             \<< 'n*p' \>>
  27.           \Gs2
  28.             \<< 'n*p*(1-p)' \>>
  29.           n 15
  30.           p .12
  31.           G '(1-p+p*e^t)^n'
  32.           RANGE
  33.             \<< \-> a b
  34.               \<< 0 a b FOR T T P + NEXT \>>
  35.             \>>
  36.         END
  37.       POIS
  38.         DIR
  39.     @ Contents:
  40.     @ POIS: Equation of Poisson distribution
  41.     @       Set value of 'np'.
  42.     @ P: Computes the equation value for a given k value
  43.     @    using the value 'np' stored into the variables.
  44.     @ \Gm: (mu)  mean of distribution.
  45.     @ \Gs2: (Sigma^2) Standard variation.
  46.     @ G: equation of momentum generator.
  47.     @ RANGE: Computes the cumulative value between
  48.     @        a and b.
  49.           POIS '\Gl^k/k!*e^-\Gl'
  50.           P
  51.             \<< \-> k '\Gl^k/k!*e^-\Gl' \->NUM \>>
  52.           \Gm np
  53.           \Gs2 np
  54.           np 3.297
  55.           \Gl np
  56.           G 'e^\Gl(e^t-1)'
  57.           RANGE
  58.             \<< \-> a b
  59.               \<< 0 a b FOR T T P + NEXT \>>
  60.             \>>
  61.         END
  62.       GAUS
  63.         DIR
  64.     @ Contents:
  65.     @ GAUS: Equation of Gauss (and Normal) distribution
  66.     @       Set value of '\Gm'(mean) and '\Gs' (sigma).
  67.     @ F: Computes the equation value for a given X value
  68.     @    using the values of mean and sigma stored into the variables.
  69.     @ P: Computes the area of the upper queue of distribution
  70.     @    between a and +infinite.
  71.     @ G: equation of momentum generator.
  72.     @ P\->X: Computes the X value for a given upper queue area R;
  73.     @        (reverse the equation: ONLY for Standard NORMAL).
  74.     @ RANGE: Computes the area of distribution between
  75.     @        a and b.
  76.           GAUS '1/(\v/(2*\pi)*\Gs)*e^(-(X-\Gm)^2/(2*\Gs^2))'
  77.           G 'e^(\Gm*t)*e^(1/2*\Gs^2*t^2)'
  78.           F
  79.             \<< 'X' STO GAUS \->NUM \>>
  80.           P
  81.             \<< \-> a
  82.               \<< \Gm \Gs 2 ^ a UTPN \>>
  83.             \>>
  84.           \Gm 0
  85.           \Gs 1
  86.           X 5
  87.           P\->X
  88.             \<<
  89.               .000001 \-> H R
  90.               \<< -6 'A' STO 6 'B' STO
  91.                 DO B A - 2 / A + 'M' STO M
  92.                   IF 0 1 M UTPN H \>=
  93.                   THEN 'A' STO
  94.                   ELSE 'B' STO
  95.                   END
  96.                 UNTIL 0 1 A UTPN H - ABS R \<=
  97.                 END
  98.               \>> A { A B M } PURGE
  99.             \>>
  100.           RANGE
  101.             \<< \-> a b
  102.               \<< a P b P - \>>
  103.             \>>
  104.         END
  105.       CHI2
  106.         DIR
  107.     @ Contents:
  108.     @ CHI2: Equation of Chi^2 distribution
  109.     @       Set value of 'v' (freedom degrees).
  110.     @ F: Computes the equation value for a given ki2 value
  111.     @    using the value of 'v' stored into the variable.
  112.     @ P: Computes the area of the upper queue of distribution
  113.     @    between a and +infinite.
  114.     @ G: equation of momentum generator.
  115.     @ CHI\->X: Computes the X value for a given upper queue area R;
  116.     @          (reverse the equation).
  117.     @ \Gs2: (Sigma^2) Standard variation.
  118.           CHI2 '1/(2^(v/2)*(v/2)!)*e^(-ki2/2)*ki2^(v/2-1)'
  119.           F
  120.             \<< 'ki2' STO CHI2 \->NUM \>>
  121.           P
  122.             \<< \-> a
  123.               \<< v a UTPC \>>
  124.             \>>
  125.           v 2
  126.           \Gs2
  127.             \<< '2*v' \->NUM \>>
  128.           ki2 .920044414629
  129.           CHI\->X
  130.             \<<
  131.               .0000001 \-> H R
  132.               \<< 0 'A' STO 200 'B' STO
  133.                 DO B A - 2 / A + 'M' STO M
  134.                   IF v M UTPC H \>=
  135.                   THEN 'A' STO
  136.                   ELSE 'B' STO
  137.                   END
  138.                 UNTIL v A UTPC H - ABS R \<=
  139.                 END
  140.               \>> A { A B M } PURGE
  141.             \>>
  142.           G '1/(1-2*t)^(v/2)'
  143.         END
  144.       GAMM
  145.         DIR
  146.     @ Contents:
  147.     @ GAMM: Equation of Gamma distribution
  148.     @       Set value of '\Gr' and 'k' (freedom degrees).
  149.     @ F: Computes the equation value for a given X value
  150.     @    using the values of '\Gr' and 'k' stored into the variables.
  151.     @ P: Computes the area of distribution
  152.     @    between a and b.
  153.     @ \Gm: (mu)  mean of distribution.
  154.     @ \Gs2: (Sigma^2) Standard variation.
  155.           GAMM '1/k!*\Gr^k*X^(k-1)*e^(-\Gr*X)'
  156.           F
  157.             \<< 'X' STO GAMM \->NUM \>>
  158.           P
  159.             \<< \-> a b
  160.               \<< a b GAMM 'X' \.S \->NUM 'IERR' PURGE \>>
  161.             \>>
  162.           \Gm
  163.             \<< 'k/\Gr' \->NUM \>>
  164.           \Gs2
  165.             \<< 'k/\Gr^ 2' \->NUM \>>
  166.           k 1
  167.           \Gr 2
  168.           X 1
  169.         END
  170.       STUD
  171.         DIR
  172.     @ Contents:
  173.     @ STUD: Equation of Student (t) distribution
  174.     @       Set value of 'v' (freedom degrees).
  175.     @ F: Computes the equation value for a given t value
  176.     @    using the value of 'v' stored into the variable.
  177.     @ P: Computes the area of the upper queue of distribution
  178.     @    between a and +infinite.
  179.     @ \Gm: (mu)  mean of distribution.
  180.     @ \Gs2: (Sigma^2) Standard variation.
  181.           STUD '((v+1)/2)!/(\v/(\pi*v)*(v/2)!)*(1/(1+t^2/v)^((v+1)/2))'
  182.           F
  183.             \<< 't' STO STUD \->NUM \>>
  184.           P
  185.             \<< \-> a
  186.               \<< v a UTPT \>>
  187.             \>>
  188.           \Gm 0
  189.           \Gs2
  190.             \<< 'v/(v-2)' \->NUM \>>
  191.           v 4
  192.           t 8
  193.         END
  194.       FISH
  195.         DIR
  196.     @ Contents:
  197.     @ FISH: Equation of Fisher (f) distribution
  198.     @       Set value of 'v' and '\Gl' (freedom degrees).
  199.     @ F: Computes the equation value for a given x value
  200.     @    using the value of 'v' stored into the variable.
  201.     @ P: Computes the area of the upper queue of distribution
  202.     @    between a and +infinite.
  203.     @ \Gm: (mu)  mean of distribution.
  204.     @ \Gs2: (Sigma^2) Standard variation.
  205.           FISH '\Gl^(\Gl/2)*v^(v/2)*((\Gl+v)/2)!/((\Gl/2)!*(v/2)!)*
  206.                 (x^((\Gl-2)/2)/(\Gl*x+v)^((\Gl+v)/2))'
  207.           F
  208.             \<< 'x' STO FISH \->NUM \>>
  209.           P
  210.             \<< \-> a
  211.               \<< \Gl v a UTPF \>>
  212.             \>>
  213.           \Gm
  214.             \<< 'v/(v -2)' \->NUM \>>
  215.           \Gs2
  216.             \<< '2*v^2*(\Gl+v-2)/(\Gl*(v-2)^2*(v-4))' \->NUM \>>
  217.           \Gl 1
  218.           v 5
  219.           x 4
  220.         END
  221.       ESPON
  222.         DIR
  223.     @ Contents:
  224.     @ ESPON: Equation of Esponential distribution
  225.     @        Set value of '\Gm' (mean).
  226.     @ F: Computes the equation value for a given X value
  227.     @    using the value of '\Gm' stored into the variable.
  228.     @ P: Computes the area of the upper queue of distribution
  229.     @    between a and +infinite.
  230.     @ \Gm: (mu) mean of distribution.
  231.           ESPON '1/\Gm*e^-(X/\Gm)'
  232.           F
  233.             \<< 'X' STO ESPON \->NUM \>>
  234.           P
  235.             \<< \-> a
  236.               \<< a .000000002 \Gm * LN \Gm
  237.                 NEG * a + ESPON 'X' \.S \->NUM
  238.               \>>
  239.             \>>
  240.           \Gm 5
  241.           X 2
  242.         END
  243.     END
  244. -----------------------------------------------------------------------
  245. Luca Radice Politecnico di Milano Italia. ele9050@cdc835.cdc.polimi.it
  246.